package com.frxuexi.reprot.entity

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

//@Preview
@Composable
fun CommitReportPage(type: String,onClick: () -> Unit, onCommitClick: (String,String,String) -> Unit) {
    var content by remember {
        mutableStateOf("")
    }
    var plan by remember {
        mutableStateOf("")
    }
    var isShow by remember {
        mutableStateOf(true)
    }

    Column(modifier = Modifier
        .fillMaxSize()
        .padding(horizontal = 20.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
        Row(modifier= Modifier.height(50.dp),verticalAlignment= Alignment.CenterVertically) {
            TextButton(onClick = { onClick() }) {
                Icon(imageVector = Icons.Default.ArrowBack, contentDescription = "")
            }
            Text(
                text = "工作汇报",
                modifier = Modifier.fillMaxWidth(),
                textAlign = TextAlign.Center
            )
        }
        var title_1:String=""
        var title_2:String=""
        if(type=="周报"){
            title_1="本周"
            title_2="下周"
        }else if(type=="月报"){
            title_1="本月"
            title_2="下月"
        }else if(type=="日报"){
            title_1="今日"
            title_2="明日"
        }else{
            isShow=false
        }

        if(isShow){
            Text(text = type)

            Text(text = "${title_1}工作总结")
        }

        OutlinedTextField(modifier = Modifier.fillMaxWidth(),value = content, onValueChange = {content=it})

        if(isShow){
            Text(text = "${title_2}计划")
        }

        OutlinedTextField(modifier = Modifier.fillMaxWidth(),value = plan, onValueChange = {plan=it})

        Button(modifier = Modifier.fillMaxWidth(),onClick = {

            onCommitClick(type,content,plan)
        }) {
            Text(text = "提交汇报")
        }
    }
}